import rxAjax from '@/assets/js/ajax.js';
import FormUtil from "@/assets/js/FormUtil";
import {Util} from '@lowcode/jpaas-common-lib';

//ureport_file api接口
export const UreportFileApi = {};

UreportFileApi.baseUrl= '/api-ureport/ureport2/core/ureportFile';
UreportFileApi.exportUrl= UreportFileApi.baseUrl + '/listExport';

UreportFileApi.doImport=function(formData,callback) {
  var url= UreportFileApi.baseUrl+"/doImport";
  return rxAjax.upload(url,formData,callback);
}


UreportFileApi.doExport = function(solutionIds) {
  solutionIds=Util.encryptWord(solutionIds);
  window.location.href='/api/api-ureport/ureport2/core/ureportFile/doExport?solutionIds=' + solutionIds;
}


//查询列表
UreportFileApi.query=function (parameter) {
  var url= UreportFileApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then (res => {
    return res.result
  })
}

/**
* 获取单记录
* @param pkId
* @returns {*}
*/
UreportFileApi.get =function(pkId) {
  var url= UreportFileApi.baseUrl + '/get?pkId=' + pkId;
  return rxAjax.get(url);
}

//保存数据
UreportFileApi.save =function(parameter) {
  var url= UreportFileApi.baseUrl + '/save';
  return rxAjax.postJson(url,parameter);
}
//查找所查询的数据并导出
UreportFileApi.listExport= function (parameter){
  var url= UreportFileApi.baseUrl + '/listExport';
  FormUtil.doExport(url,parameter);
}

//删除数据
UreportFileApi.del =function(parameter) {
  var url= UreportFileApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}
//更新数据
UreportFileApi.update =function(parameter) {
    var url= UreportFileApi.baseUrl + '/update';
    return rxAjax.postJson(url,parameter);
}

UreportFileApi.updExport =function(ids) {
    var url= UreportFileApi.baseUrl + '/updExport';
    return rxAjax.postForm(url,{ids:ids});
}
//变更分类
UreportFileApi.changeCategory=function(ids,categoryId){
    var url= UreportFileApi.baseUrl+'/changeCategory';
    return rxAjax.postForm(url, {ids:ids,categoryId:categoryId});
}

export  default UreportFileApi;

